package com.runfast.paotui.utils;

import com.alibaba.fastjson.JSON;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Date;


@Configuration
public class RabbitConfig {

   /* @Bean
    public Queue Queue() {
        return new Queue("hellowo");
    }

    @Bean
    public Queue Queue1() {
        return new Queue("waimai");
    }
    @Bean
    public Queue Queue2() {
        return new Queue("paotui");
    }*/

   //广播
    @Bean
    public FanoutExchange exchange() {
        return new FanoutExchange("pt_shopper_order_exchange");
    }
    @Bean
    public FanoutExchange exchange2() {
        return new FanoutExchange("wm_shopper_order_exchange");
    }
    @Bean
    public FanoutExchange exchange3() {
        return new FanoutExchange("shopper_exchange");
    }

    //单独
    @Bean
    public Exchange exchange4() {
        //设置路由名
        return new FanoutExchange("wm_finish_router_order_exchange");
        //单个接收
        //amqpTemplate.convertAndSend("wm_finish_router_order_exchange","wm_finish_order_exchange",JSON.toJSONString(gr));
    }
    @Bean
    public Queue exchange5() {
        return new Queue("wm_finish_order_exchange");
    }


    @Bean
    public Binding information_serviceBinding() {
        return BindingBuilder.bind(exchange5()).to(exchange4()).with("wm_finish_order_exchange").noargs();
    }

}
